home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / scripts / control / abcddim.m next >
Text File  |  1996-07-11  |  2KB  |  72 lines

  1. ## Copyright (C) 1996 John W. Eaton
  2. ##
  3. ## This file is part of Octave.
  4. ##
  5. ## Octave is free software; you can redistribute it and/or modify it
  6. ## under the terms of the GNU General Public License as published by
  7. ## the Free Software Foundation; either version 2, or (at your option)
  8. ## any later version.
  9. ##
  10. ## Octave is distributed in the hope that it will be useful, but
  11. ## WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. ## General Public License for more details.
  14. ##
  15. ## You should have received a copy of the GNU General Public License
  16. ## along with Octave; see the file COPYING.  If not, write to the Free
  17. ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  18. ## 02111-1307, USA.
  19.  
  20. ## Usage: [n, m, p] = abcddim (a, b, c, d)
  21. ##
  22. ## Check for compatibility of the dimensions of the matrices defining
  23. ## the linear system (a, b, c, d).
  24. ##
  25. ## Returns n = number of system states,
  26. ##         m = number of system inputs,
  27. ##         p = number of system outputs.
  28. ##
  29. ## Returns n = m = p = -1 if the system is not compatible.
  30.  
  31. ## Author: A. S. Hodel <scotte@eng.auburn.edu>
  32. ## Created: August 1993
  33. ## Adapted-By: jwe
  34.  
  35. function [n, m, p] = abcddim (a, b, c, d)
  36.  
  37.   if (nargin != 4)
  38.     error ("usage: abcddim (a, b, c, d)");
  39.   endif
  40.  
  41.   n = m = p = -1;
  42.  
  43.   [an, am] = size(a);
  44.   if (an != am)
  45.     error ("abcddim: a is not square");
  46.   endif
  47.  
  48.   [bn, bm] = size(b);
  49.   if (bn != am)
  50.     error ("abcddim: a and b are not compatible");
  51.   endif
  52.  
  53.   [cn, cm] = size(c);
  54.   if (cm != an)
  55.     error ("abcddim: a and c are not compatible");
  56.   endif
  57.  
  58.   [dn, dm] = size(d);
  59.   if (cn != dn)
  60.     error ("abcddim: c and d are not compatible");
  61.   endif
  62.  
  63.   if (bm != dm)
  64.     error ("abcddim: b and d are not compatible");
  65.   endif
  66.  
  67.   n = an;
  68.   m = bm;
  69.   p = cn;
  70.  
  71. endfunction
  72.